<?php
/**
  * Cefiro's mailer utility widget, it has a simple interface and some wrapping
  * functions.
  * @file mailer.php
  * @author DYR Technologies
  * @version V 1.1
  * @date Wed Oct 03 2007
 *
 *  Part of the CEFIRO dynamic web framework project
 *
 *  Copyright (C) 2007  Dyr technologies http://dyrtech.com.ve
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  */

class mailer{
  private $to;
  private $from;
  private $subject;
  private $message;
  private $headers;

  public function mailer($_to = '', $_from = '', $_subject = '', $_message = '', $_headers = '') {
    $this->to = $_to;
    $this->from = $_from;
    $this->subject = $_subject;
    $this->message = $_message;
    $this->headers = $_headers;
  }

  public function send(){
    if ($_headers === '')
      $_headers ="From: $_from\r\nReply-To: $_from\r\nX-Mailer: PHP/".phpversion();
  }

  static public function mail($_to, $_from, $_subject, $_message, $_headers = '') {
    if ($_headers === '')
      $_headers ="From: $_from\r\nReply-To: $_from\r\nX-Mailer: PHP/".phpversion();
    $ret = mail($_to,$_subject,$_message,$_headers);
    error_log($ret?'mailed':'mailer error');
    return $ret;
  }
}